package beans;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "maquina")
@NamedQueries({
    @NamedQuery(name = "Maquina.findAll", query = "SELECT m FROM Maquina m"),
    @NamedQuery(name = "Maquina.findByIdmaquina", query = "SELECT m FROM Maquina m WHERE m.idmaquina = :idmaquina"),
    @NamedQuery(name = "Maquina.findByPatrimonio", query = "SELECT m FROM Maquina m WHERE m.patrimonio = :patrimonio"),
    @NamedQuery(name = "Maquina.findByDescricao", query = "SELECT m FROM Maquina m WHERE m.descricao = :descricao")})
public class Maquina implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "idmaquina")
    private Integer idmaquina;
    @Column(name = "patrimonio")
    private BigInteger patrimonio;
    @Column(name = "descricao")
    private String descricao;
    @ManyToMany(mappedBy = "maquinaList")
    private List<Departamento> departamentoList;
    @OneToMany(mappedBy = "maquina")
    private List<Usuario> usuarioList;

    public Maquina() {
    }

    public Maquina(Integer idmaquina) {
        this.idmaquina = idmaquina;
    }

    public Integer getIdmaquina() {
        return idmaquina;
    }

    public void setIdmaquina(Integer idmaquina) {
        this.idmaquina = idmaquina;
    }

    public BigInteger getPatrimonio() {
        return patrimonio;
    }

    public void setPatrimonio(BigInteger patrimonio) {
        this.patrimonio = patrimonio;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public List<Departamento> getDepartamentoList() {
        return departamentoList;
    }

    public void setDepartamentoList(List<Departamento> departamentoList) {
        this.departamentoList = departamentoList;
    }

    public List<Usuario> getUsuarioList() {
        return usuarioList;
    }

    public void setUsuarioList(List<Usuario> usuarioList) {
        this.usuarioList = usuarioList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmaquina != null ? idmaquina.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Maquina)) {
            return false;
        }
        Maquina other = (Maquina) object;
        if ((this.idmaquina == null && other.idmaquina != null) || (this.idmaquina != null && !this.idmaquina.equals(other.idmaquina))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "beans.Maquina[idmaquina=" + idmaquina + "]";
    }

}
//@Entity
//public class Maquina implements Serializable{
//	private static final long serialVersionUID = 1L;
//	
//	@Id
//    @GeneratedValue(strategy=GenerationType.IDENTITY)
//    private Long idMaquina;
//    private String descricao;
//    private Long patrimonio;
//   
//    @OneToOne(mappedBy = "maquina")
//    private Usuario usuario;
//
//    //metodos
//    public String getDescricao() {
//        return descricao;
//    }
//
//    public void setDescricao(String descricao) {
//        this.descricao = descricao;
//    }
//
//    public Long getIdMaquina() {
//        return idMaquina;
//    }
//
//    public void setIdMaquina(Long idMaquina) {
//        this.idMaquina = idMaquina;
//    }
//
//    public Long getPatrimonio() {
//        return patrimonio;
//    }
//
//    public void setPatrimonio(Long patrimonio) {
//        this.patrimonio = patrimonio;
//    }
//
//    
//
//}
